package it.polito.ai.lhmf.orm;

// Generated 8-giu-2012 18.52.32 by Hibernate Tools 3.4.0.CR1

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Order generated by hbm2java
 */
@Entity
@Table(name = "order")
public class Order implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int idOrder;
	private Supplier supplier;
	private Member member;
	private Date dateOpen;
	private Date dateClose;
	private Date dateDelivery;
	private Set<Purchase> purchases = new HashSet<Purchase>(0);
	private Set<Product> products = new HashSet<Product>(0);

	public Order() {
	}

	public Order(int idOrder, Supplier supplier, Member member, Date dateOpen,
			Date dateClose) {
		this.idOrder = idOrder;
		this.supplier = supplier;
		this.member = member;
		this.dateOpen = dateOpen;
		this.dateClose = dateClose;
	}

	public Order(int idOrder, Supplier supplier, Member member, Date dateOpen,
			Date dateClose, Date dateDelivery, Set<Purchase> purchases, Set<Product> products) {
		this.idOrder = idOrder;
		this.supplier = supplier;
		this.member = member;
		this.dateOpen = dateOpen;
		this.dateClose = dateClose;
		this.dateDelivery = dateDelivery;
		this.purchases = purchases;
		this.products = products;
	}

	@Id
	@Column(name = "idOrder", unique = true, nullable = false)
	public int getIdOrder() {
		return this.idOrder;
	}

	public void setIdOrder(int idOrder) {
		this.idOrder = idOrder;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idMember_supplier", nullable = false)
	public Supplier getSupplier() {
		return this.supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idMember_resp", nullable = false)
	public Member getMember() {
		return this.member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "date_open", nullable = false, length = 10)
	public Date getDateOpen() {
		return this.dateOpen;
	}

	public void setDateOpen(Date dateOpen) {
		this.dateOpen = dateOpen;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "date_close", nullable = false, length = 10)
	public Date getDateClose() {
		return this.dateClose;
	}

	public void setDateClose(Date dateClose) {
		this.dateClose = dateClose;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "date_delivery", length = 10)
	public Date getDateDelivery() {
		return this.dateDelivery;
	}

	public void setDateDelivery(Date dateDelivery) {
		this.dateDelivery = dateDelivery;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "order")
	public Set<Purchase> getPurchases() {
		return this.purchases;
	}

	public void setPurchases(Set<Purchase> purchases) {
		this.purchases = purchases;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "order_product", catalog = "malnati_project", joinColumns = { @JoinColumn(name = "idOrder", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "idProduct", nullable = false, updatable = false) })
	public Set<Product> getProducts() {
		return this.products;
	}

	public void setProducts(Set<Product> products) {
		this.products = products;
	}

}
